﻿using System.Collections.Specialized;

namespace Sidvall.Web
{
    public static class RequestManager
    {
        #region GetAccessToken

        public static string GetAccessToken(NameValueCollection headers, NameValueCollection formValues)
        {
            if (headers != null)
            {
                string headerValue = headers["Authorization"];
                if (!string.IsNullOrWhiteSpace(headerValue))
                {
                    string[] values = headerValue.Split(new string[] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
                    if (values.Length > 1)
                        return values[1];
                }
            }

            if (formValues != null)
            {
                return formValues[Sidvall.Security.ClaimTypes.AccessToken];
            }

            return null;
        }

        #endregion
    }
}
